package com.study.manager;

import com.study.utils.ImageReader;
import com.study.utils.ImageUtil;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;

/**
 * 资源文件管理类
 * @Author ZhuHJay
 * @Date 2021/9/14 20:03
 */
public class ResourceManager {

    /** 坦克的方位图 **/
    public static BufferedImage myTankUP, myTankLEFT, myTankDOWN, myTankRIGHT;
    public static BufferedImage tankUP, tankLEFT, tankDOWN, tankRIGHT;
    /** 子弹的方位图 **/
    public static BufferedImage bulletUP, bulletLEFT, bulletDOWN, bulletRIGHT;
    /** 爆炸的图片集合 **/
    public static List<BufferedImage> explodes = new ArrayList<>();

    static {
        try{
            tankUP = ImageReader.loaderImage("images/BadTank1.png");
            tankLEFT = ImageUtil.rotateImage(tankUP, -90);
            tankDOWN = ImageUtil.rotateImage(tankUP, 180);
            tankRIGHT = ImageUtil.rotateImage(tankUP, 90);

            myTankUP = ImageReader.loaderImage("images/GoodTank1.png");
            myTankLEFT = ImageUtil.rotateImage(myTankUP, -90);
            myTankDOWN = ImageUtil.rotateImage(myTankUP, 180);
            myTankRIGHT = ImageUtil.rotateImage(myTankUP, 90);

            bulletUP = ImageReader.loaderImage("images/bulletU.gif");
            bulletLEFT = ImageReader.loaderImage("images/bulletL.gif");
            bulletDOWN = ImageReader.loaderImage("images/bulletD.gif");
            bulletRIGHT = ImageReader.loaderImage("images/bulletR.gif");

            for (int i = 0; i < 16; i++) {
                explodes.add(
                        ImageReader.loaderImage("images/e" + (i+1) + ".gif") );
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
